
cmake_minimum_required(VERSION 2.8)

#--- имя проекта совпадает с именем каталога проекта
get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)

#--- имя главной цели. CXX значает, что проект на с++
project( ${PROJECT_NAME} CXX )

#------------------ библиотеки буста-----------------------------------------------------------------
set(BOOST_COMPONENTS system filesystem regex)

#----- настройки компиляции
include (${CMAKE_CURRENT_SOURCE_DIR}/cmake/setup.cmake)
#------------------ исходные файлы продукта ----------------------------------------------------------

file (GLOB _unit_test_hpp "include/${PROJECT_NAME}/*.h"   )
file (GLOB _unit_test_cpp "src/*.cpp" )
file (GLOB _unit_test_cpp1 "src/*.hpp" )
file (GLOB _unit_test_cpp2 "src/*.h" )
set(unit_test ${_unit_test_hpp} ${_unit_test_cpp} ${_unit_test_cpp1} ${_unit_test_cpp2})

file (GLOB _lib_hpp "${CMAKE_CURRENT_SOURCE_DIR}/../include/os/*.h"   )
file (GLOB _lib_cpp "${CMAKE_CURRENT_SOURCE_DIR}/../src/*.cpp" )
set(libos ${_lib_hpp} ${_lib_cpp} )

source_group(unit_test FILES ${unit_test} )
source_group(os FILES ${libos} )

set (PRODUCT_SOURCES_FILES ${libos} ${unit_test} )

#------------------ пути к хэдерам -------------------------------------------------------------------
set (PATH_INCLUDES
    ${MY_EXTERNAL_DIR}/gtest/include 
#    ${MY_EXTERNAL_DIR}/os/include 
    ${CMAKE_CURRENT_SOURCE_DIR}/../include
    ${Boost_INCLUDE_DIRS} 
)
#------------------ пути к библиотекам -------------------------------------------------------------------
set (PATH_LIB  
    ${Boost_LIBRARY_DIRS}   
#    ${MY_EXTERNAL_DIR}/os/lib
    ${MY_EXTERNAL_DIR}/gtest/lib${ADDRESS_MODEL}
)

#------------------ имена библиотек ----------------------------------------------------------------------
if ( ${CMAKE_BUILD_TYPE} MATCHES "Debug" OR ${CMAKE_BUILD_TYPE} MATCHES "debug")
    set(LIBRARIES ${Boost_REGEX_LIBRARY_DEBUG} ${Boost_SYSTEM_LIBRARY_DEBUG} ${Boost_FILESYSTEM_LIBRARY_DEBUG} )
else()
    set(LIBRARIES ${Boost_REGEX_LIBRARY_RELEASE} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_FILESYSTEM_LIBRARY_RELEASE} )
endif()

list(APPEND LIBRARIES
#    ${MY_EXTERNAL_DIR}/os/lib/os-${ADDRESS_MODEL}${MY_DEBUG_MARKER}${CMAKE_STATIC_LIBRARY_SUFFIX}
    ${MY_EXTERNAL_DIR}/gtest/lib${ADDRESS_MODEL}/gtest_denmain-${ADDRESS_MODEL}${MY_DEBUG_MARKER}${CMAKE_STATIC_LIBRARY_SUFFIX}
    ${MY_EXTERNAL_DIR}/gtest/lib${ADDRESS_MODEL}/gtest-${ADDRESS_MODEL}${MY_DEBUG_MARKER}${CMAKE_STATIC_LIBRARY_SUFFIX}
)

#----------------------------------------------
include_directories( ${PATH_INCLUDES} )
link_directories   ( ${PATH_LIB}      )

message(STATUS "============================================================" )
view_console("caption:BOOST FOUND"  ${BOOST_ROOT} )
view_console("caption:LIBRARY_DIRS" ${PATH_LIB} )
view_console("caption:INCLUDE_DIRS" ${PATH_INCLUDES} )
view_console("caption:LIBRARIES"    ${LIBRARIES} )
view_console("caption:PRODUCT_SOURCES_FILES"    ${PRODUCT_SOURCES_FILES} )
message(STATUS "============================================================" )
#----------------------------------------------------------------------------
add_executable (${PROJECT_NAME}  ${PRODUCT_SOURCES_FILES} )

set(file_pdb ${CMAKE_BUILD_TYPE}/${PROJECT_NAME}.pdb )
set_target_properties(${PROJECT_NAME}
    PROPERTIES
    COMPILE_FLAGS "/Fd\"${file_pdb}\""
) 

target_link_libraries (${PROJECT_NAME} ${LIBRARIES})
target_link_libraries (${PROJECT_NAME} ${LIBRARIES})
